#!/usr/bin/python
# -*- coding: utf8 -*-

class RfFile:
	def __init__(self):
		
		##reading the configuration file
		rf_file = open("/etc/bluetooth/rfcomm.conf", "r")
		try:
			rf_raw_lines = rf_file.readlines()
		finally:
			rf_file.close()
		
		##creating a list for cleared wersion of source
		self.__rf_lines = []
		
		## tiding source
		for line in rf_raw_lines:
			stripped_line = line.strip()
			if not (stripped_line.startswith('#') or stripped_line.startswith(';') or stripped_line == ""):
				##line is not a comment nor a white line
				self.__rf_lines.append(stripped_line)
		##rf_raw_lines won't be usefull any more
		del rf_raw_lines
		
		#~ for line in self.__rf_lines:
			#~ print line
			
	def lines(self):
		return self.__rf_lines
if __name__ == "__main__":
	devices_text = ""
	max_line_length = 0
	test_file = RfFile()
	for line in test_file.lines():
		devices_text += line + "\n"
		if len(line) > max_line_length:
			max_line_length = len(line)

	import Tkinter
	app = Tkinter.Tk()
	app.title("rfcomm.conf")
	
	quit_button = Tkinter.Button(app, text="Quit", command=app.destroy)
	quit_button.pack(side = "bottom", fill = "x")
	
	scrollbar = Tkinter.Scrollbar(app)
	scrollbar.pack(side="right", fill="y")
	
	text_field = Tkinter.Text(app, yscrollcommand=scrollbar.set, width = max_line_length * 2)
	text_field.insert('insert', devices_text)
	text_field.pack()
	

	app.mainloop()